package threadlocal;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 描述：两个线程打印日期
 */

public class ThreadLocalNormalUsage00 {
    public String date(int seconds) {
        // 参数的单位是毫秒，从1970.1.1 0:00:00 GMT计时 对于中国来说，要加上8个小时
        Date date = new Date(1000L * seconds);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return dateFormat.format(date);
    }
    public static void main(String[] args) {
        new Thread(() -> {
            String date = new ThreadLocalNormalUsage00().date(10);
            System.out.println(date);
        }).start();
        new Thread(() -> {
            String date = new ThreadLocalNormalUsage00().date(1000);
            System.out.println(date);
        }).start();
    }
}
